package com.wwh.service.impl;

import com.wwh.entity.Monster;
import com.wwh.service.MonsterService;
import com.wwh.wwhspringmvc.annotation.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Albert
 * @date 2024/9/5-20:27
 * @describe
 */
@Service
public class MonsterServiceImpl implements MonsterService {

    @Override
    public boolean login(String name) {
        return "wwh".equals(name);
    }

    @Override
    public List<Monster> findMonsterByName(String name) {
        List<Monster> monsters = new ArrayList<>();
        monsters.add(new Monster(100, "牛魔王", "芭蕉扇", 400));
        monsters.add(new Monster(200, "老猫妖怪", "抓老鼠", 200));
        monsters.add(new Monster(300, "白骨妖怪", "抓老鼠", 200));
        monsters.add(new Monster(400, "大王", "抓老鼠", 200));

        List<Monster> findMonsters = new ArrayList<>();
        for (Monster monster : monsters) {
            if(monster.getName().contains(name)){
                findMonsters.add(monster);
            }
        }
        return findMonsters;
    }

    public List<Monster> listMonster() {
        List<Monster> monsters = new ArrayList<>();
        monsters.add(new Monster(100, "牛魔王", "芭蕉扇", 400));
        monsters.add(new Monster(200, "老猫妖怪", "抓老鼠", 200));
        return monsters;
    }
}
